# coding utf-8
import os
import xml.dom.minidom
from moviepy.editor import *

path = "D:/sss"

# 在内存中创建一个空的文档
doc = xml.dom.minidom.Document ( )
# 创建一个根节点Managers对象
root = doc.createElement ( 'xmeml' )
# 设置根节点的属性
root.setAttribute ( 'version', '4' )
doc.appendChild ( root )
Sequence = doc.createElement ( "sequence" )
Sequence.setAttribute ( 'id', 'sequence-1' )
Sequence.setAttribute ( 'TL.SQAudioVisibleBase', '0' )
sequence_uuid = doc.createElement ( 'uuid' )
sequence_uuid.appendChild ( doc.createTextNode ( "4a9cd416-0d6b-4535-b532-f15629838f10" ) )
sequence_duration = doc.createElement ( 'duration' )  # 序列总帧数
sequence_rate = doc.createElement ( 'rate' )  # 序列进度
sequence_rate_timebase = doc.createElement ( 'timebase' )  # 序列总帧数
sequence_rate_timebase.appendChild ( doc.createTextNode ( "25" ) )
sequence_rate_ntsc = doc.createElement ( 'ntsc' )  # 序列总帧数
sequence_rate_ntsc.appendChild ( doc.createTextNode ( "TRUE" ) )
sequence_rate.appendChild ( sequence_rate_timebase )
sequence_rate.appendChild ( sequence_rate_ntsc )
sequence_name = doc.createElement ( 'name' )  # 序列名字
sequence_name.appendChild ( doc.createTextNode ( "EP009" ) )
sequence_media = doc.createElement ( 'media' )
sequence_media_video = doc.createElement ( 'video' )
sequence_media_video_format = doc.createElement ( 'format' )
sequence_media_video_format_samplecharacteristics = doc.createElement ( 'samplecharacteristics' )
sequence_media_video_format_samplecharacteristics_rate = doc.createElement ( 'rate' )
sequence_media_video_format_samplecharacteristics_rate_timebase = doc.createElement ( 'timebase' )
sequence_media_video_format_samplecharacteristics_rate_timebase.appendChild ( doc.createTextNode ( "25" ) )
sequence_media_video_format_samplecharacteristics_rate_ntsc = doc.createElement ( 'ntsc' )
sequence_media_video_format_samplecharacteristics_rate_ntsc.appendChild ( doc.createTextNode ( "TRUE" ) )
sequence_media_video_format_samplecharacteristics_rate.appendChild ( sequence_media_video_format_samplecharacteristics_rate_timebase )
sequence_media_video_format_samplecharacteristics_rate.appendChild ( sequence_media_video_format_samplecharacteristics_rate_ntsc )
sequence_media_video_format_samplecharacteristics_rate.appendChild ( sequence_media_video_format_samplecharacteristics_rate_timebase )
sequence_media_video_format_samplecharacteristics_rate.appendChild ( sequence_media_video_format_samplecharacteristics_rate_ntsc )
sequence_media_video_format_samplecharacteristics_codec = doc.createElement ( 'codec' )
sequence_media_video_format_samplecharacteristics_codec_name = doc.createElement ( 'name' )
sequence_media_video_format_samplecharacteristics_codec_name.appendChild ( doc.createTextNode ( "Apple ProRes 422" ) )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata = doc.createElement ( 'appspecificdata' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appname = doc.createElement ( 'appname' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appname.appendChild ( doc.createTextNode ( 'Final Cut Pro' ) )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appmanufacturer = doc.createElement ( 'appmanufacturer' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appmanufacturer.appendChild ( doc.createTextNode ( "Apple Inc." ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appversion = doc.createElement ( 'appversion' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appversion.appendChild ( doc.createTextNode ( "7.0" ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data = doc.createElement ( 'data' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec = doc.createElement ( 'qtcodec' )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codecname = doc.createElement ( 'codecname' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codecname.appendChild ( doc.createTextNode ( "Apple ProRes 422" ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codectypename = doc.createElement ( 'codectypename' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codectypename.appendChild ( doc.createTextNode ( "Apple ProRes 422" ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codectypecode = doc.createElement ( 'codectypecode' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codectypecode.appendChild ( doc.createTextNode ( "apcn" ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codecvendorcode = doc.createElement ( 'codecvendorcode' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codecvendorcode.appendChild ( doc.createTextNode ( 'appl' ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_spatialquality = doc.createElement ( 'spatialquality' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_spatialquality.appendChild ( doc.createTextNode ( "1024" ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_temporalquality = doc.createElement ( 'temporalquality' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_temporalquality.appendChild ( doc.createTextNode ( "0" ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_keyframerate = doc.createElement ( 'keyframerate' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_keyframerate.appendChild ( doc.createTextNode ( "0" ) )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_datarate = doc.createElement ( 'datarate' )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_datarate.appendChild ( doc.createTextNode ( "0" ) )
sequence_media_video_format_samplecharacteristics_width = doc.createElement ( 'width' )

sequence_media_video_format_samplecharacteristics_height = doc.createElement ( 'height' )

sequence_media_video_format_samplecharacteristics_anamorphic = doc.createElement ( 'anamorphic' )
sequence_media_video_format_samplecharacteristics_anamorphic.appendChild ( doc.createTextNode ( "FALSE" ) )

sequence_media_video_format_samplecharacteristics_pixelaspectratio = doc.createElement ( 'pixelaspectratio' )
sequence_media_video_format_samplecharacteristics_pixelaspectratio.appendChild ( doc.createTextNode ( "square" ) )

sequence_media_video_format_samplecharacteristics_fielddominance = doc.createElement ( 'fielddominance' )
sequence_media_video_format_samplecharacteristics_fielddominance.appendChild ( doc.createTextNode ( "none" ) )

sequence_media_video_format_samplecharacteristics_colordepth = doc.createElement ( 'colordepth' )
sequence_media_video_format_samplecharacteristics_colordepth.appendChild ( doc.createTextNode ( "24" ) )

Sequence.appendChild ( sequence_uuid )
Sequence.appendChild ( sequence_duration )
Sequence.appendChild ( sequence_rate )
Sequence.appendChild ( sequence_name )
sequence_media.appendChild ( sequence_media_video )
sequence_media_video.appendChild ( sequence_media_video_format )
sequence_media_video_format.appendChild ( sequence_media_video_format_samplecharacteristics )
sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_rate )

sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_codec )
sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_width )
sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_height )
sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_anamorphic )
sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_pixelaspectratio )
sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_fielddominance )
sequence_media_video_format_samplecharacteristics.appendChild ( sequence_media_video_format_samplecharacteristics_colordepth )

sequence_media_video_format_samplecharacteristics_codec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_name )
sequence_media_video_format_samplecharacteristics_codec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata )

sequence_media_video_format_samplecharacteristics_codec_appspecificdata.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appname )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appmanufacturer )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_appversion )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codecname )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codectypename )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codectypecode )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_codecvendorcode )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_spatialquality )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_temporalquality )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_keyframerate )
sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec.appendChild ( sequence_media_video_format_samplecharacteristics_codec_appspecificdata_data_qtcodec_datarate )

sequence_media_video_track = doc.createElement ( "track" )
sequence_media_video_track.setAttribute ( 'TL.SQTrackShy', '0' )
sequence_media_video_track.setAttribute ( 'TL.SQTrackExpandedHeight', '25' )
sequence_media_video_track.setAttribute ( 'TL.SQTrackExpanded', '0' )
sequence_media_video_track.setAttribute ( 'TL.TrackTargeted', '1' )
sequence_media_audio = doc.createElement ( 'audio' )
sequence_media_audio_track = doc.createElement ( 'track' )
sequence_media_audio_track.setAttribute ( 'TL.SQTrackAudioKeyframeStyle', "0" )

sequence_media_audio.appendChild ( sequence_media_audio_track )

start_frames = 0
end_frames = 0
sequence_duration_str = 0
audio_set = [ ]
files = os.listdir ( path )
for file in range ( len ( files ) ) :
    fileName = files [ file ]
    clip = VideoFileClip ( path + "/" + files [ file ] )
    width = clip.size [ 0 ]
    height = clip.size [ 1 ]
    frame_rate = str ( int ( clip.fps ) )

    from decimal import Decimal

    n_frames = clip.duration * clip.fps
    n_frames = round ( Decimal ( n_frames ), 0 )
    print ( n_frames )
    # n_frames = clip.reader.nframes - 1
    sequence_duration_str = sequence_duration_str + n_frames

    end_frames = int ( end_frames ) + int ( n_frames )

    clipitem_video_Id = "clipitem-" + str ( file )
    clipitem_audio_Id = "clipitem-" + str ( file + 1 )

    masterclipid = "masterclip-" + str ( file )

    linkclipref_video = clipitem_video_Id
    linkclipref_audio = clipitem_audio_Id
    # print(file)

    sequence_media_video_track_clipitem = doc.createElement ( "clipitem" )
    sequence_media_video_track_clipitem.setAttribute ( 'id', clipitem_video_Id )

    sequence_media_video_track_clipitem_masterclipid = doc.createElement ( "masterclipid" )
    sequence_media_video_track_clipitem_masterclipid.appendChild ( doc.createTextNode ( masterclipid ) )

    sequence_media_video_track_clipitem_name = doc.createElement ( "name" )
    sequence_media_video_track_clipitem_name.appendChild ( doc.createTextNode ( files [ file ] ) )

    sequence_media_video_track_clipitem_enabled = doc.createElement ( "enabled" )
    sequence_media_video_track_clipitem_enabled.appendChild ( doc.createTextNode ( "TRUE" ) )

    sequence_media_video_track_clipitem_duration = doc.createElement ( "duration" )
    sequence_media_video_track_clipitem_duration.appendChild ( doc.createTextNode ( str ( n_frames ) ) )

    sequence_media_video_track_clipitem_rate = doc.createElement ( "rate" )

    sequence_media_video_track_clipitem_rate_timebase = doc.createElement ( "timebase" )
    sequence_media_video_track_clipitem_rate_timebase.appendChild ( doc.createTextNode ( frame_rate ) )

    sequence_media_video_track_clipitem_rate_ntsc = doc.createElement ( "ntsc" )
    sequence_media_video_track_clipitem_rate_ntsc.appendChild ( doc.createTextNode ( "TRUE" ) )

    sequence_media_video_track_clipitem_rate.appendChild ( sequence_media_video_track_clipitem_rate_timebase )
    sequence_media_video_track_clipitem_rate.appendChild ( sequence_media_video_track_clipitem_rate_ntsc )

    sequence_media_video_track_clipitem_start = doc.createElement ( "start" )
    sequence_media_video_track_clipitem_start.appendChild ( doc.createTextNode ( str ( start_frames ) ) )

    sequence_media_video_track_clipitem_end = doc.createElement ( "end" )
    sequence_media_video_track_clipitem_end.appendChild ( doc.createTextNode ( str ( end_frames ) ) )

    sequence_media_video_track_clipitem_in = doc.createElement ( "in" )
    sequence_media_video_track_clipitem_in.appendChild ( doc.createTextNode ( "0" ) )

    sequence_media_video_track_clipitem_out = doc.createElement ( "out" )
    sequence_media_video_track_clipitem_out.appendChild ( doc.createTextNode ( str ( n_frames ) ) )

    sequence_media_video_track_clipitem_pproTicksIn = doc.createElement ( "pproTicksIn" )
    sequence_media_video_track_clipitem_pproTicksIn.appendChild ( doc.createTextNode ( "0" ) )

    sequence_media_video_track_clipitem_pproTicksOut = doc.createElement ( "pproTicksOut" )
    sequence_media_video_track_clipitem_pproTicksOut.appendChild ( doc.createTextNode ( "" ) )

    sequence_media_video_track_clipitem_alphatype = doc.createElement ( "alphatype" )
    sequence_media_video_track_clipitem_alphatype.appendChild ( doc.createTextNode ( "none" ) )

    sequence_media_video_track_clipitem_pixelaspectratio = doc.createElement ( "pixelaspectratio" )
    sequence_media_video_track_clipitem_pixelaspectratio.appendChild ( doc.createTextNode ( "square" ) )

    sequence_media_video_track_clipitem_anamorphic = doc.createElement ( "anamorphic" )
    sequence_media_video_track_clipitem_anamorphic.appendChild ( doc.createTextNode ( "FALSE" ) )

    sequence_media_video_track_clipitem_file = doc.createElement ( "file" )
    sequence_media_video_track_clipitem_file.setAttribute ( 'id', 'file-' + str ( file ) )

    sequence_media_video_track_clipitem_file_name = doc.createElement ( "name" )
    sequence_media_video_track_clipitem_file_name.appendChild ( doc.createTextNode ( files [ file ] ) )

    sequence_media_video_track_clipitem_file_pathurl = doc.createElement ( "pathurl" )
    sequence_media_video_track_clipitem_file_pathurl.appendChild ( doc.createTextNode ( path + "/" + files [ file ] ) )

    sequence_media_video_track_clipitem_file_rate = doc.createElement ( "rate" )

    sequence_media_video_track_clipitem_file_rate_timebase = doc.createElement ( "timebase" )
    sequence_media_video_track_clipitem_file_rate_timebase.appendChild ( doc.createTextNode ( frame_rate ) )

    sequence_media_video_track_clipitem_file_rate_ntsc = doc.createElement ( "ntsc" )
    sequence_media_video_track_clipitem_file_rate_ntsc.appendChild ( doc.createTextNode ( "TRUE" ) )

    sequence_media_video_track_clipitem_file_rate.appendChild ( sequence_media_video_track_clipitem_file_rate_timebase )
    sequence_media_video_track_clipitem_file_rate.appendChild ( sequence_media_video_track_clipitem_file_rate_ntsc )

    sequence_media_video_track_clipitem_file_duration = doc.createElement ( "duration" )
    sequence_media_video_track_clipitem_file_duration.appendChild ( doc.createTextNode ( str ( n_frames ) ) )
    sequence_media_video_track_clipitem_file_timecode = doc.createElement ( "timecode" )
    sequence_media_video_track_clipitem_file_timecode_rate = doc.createElement ( "rate" )
    sequence_media_video_track_clipitem_file_timecode_rate_timebase = doc.createElement ( "timebase" )
    sequence_media_video_track_clipitem_file_timecode_rate_timebase.appendChild ( doc.createTextNode ( frame_rate ) )
    sequence_media_video_track_clipitem_file_timecode_rate_ntsc = doc.createElement ( "ntsc" )
    sequence_media_video_track_clipitem_file_timecode_rate_ntsc.appendChild ( doc.createTextNode ( "TRUE" ) )
    sequence_media_video_track_clipitem_file_timecode_rate.appendChild ( sequence_media_video_track_clipitem_file_timecode_rate_timebase )
    sequence_media_video_track_clipitem_file_timecode_rate.appendChild ( sequence_media_video_track_clipitem_file_timecode_rate_ntsc )
    sequence_media_video_track_clipitem_file_timecode.appendChild ( sequence_media_video_track_clipitem_file_timecode_rate )
    sequence_media_video_track_clipitem_file_timecode_string = doc.createElement ( "string" )
    sequence_media_video_track_clipitem_file_timecode_string.appendChild ( doc.createTextNode ( "00:00:00:00" ) )
    sequence_media_video_track_clipitem_file_timecode_frame = doc.createElement ( "frame" )
    sequence_media_video_track_clipitem_file_timecode_frame.appendChild ( doc.createTextNode ( "0" ) )
    sequence_media_video_track_clipitem_file_timecode_displayformat = doc.createElement ( "displayformat" )
    sequence_media_video_track_clipitem_file_timecode_displayformat.appendChild ( doc.createTextNode ( "NDF" ) )
    sequence_media_video_track_clipitem_file_timecode.appendChild ( sequence_media_video_track_clipitem_file_timecode_string )
    sequence_media_video_track_clipitem_file_timecode.appendChild ( sequence_media_video_track_clipitem_file_timecode_frame )
    sequence_media_video_track_clipitem_file_timecode.appendChild ( sequence_media_video_track_clipitem_file_timecode_displayformat )
    sequence_media_video_track_clipitem_media = doc.createElement ( "media" )
    sequence_media_video_track_clipitem_media_video = doc.createElement ( "video" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics = doc.createElement ( "samplecharacteristics" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate = doc.createElement ( "rate" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate_timebase = doc.createElement ( "timebase" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate_timebase.appendChild ( doc.createTextNode ( frame_rate ) )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate_ntsc = doc.createElement ( "ntsc" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate_ntsc.appendChild ( doc.createTextNode ( "TRUE" ) )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate_timebase )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate_ntsc )
    # 视频尺寸
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_width = doc.createElement ( "width" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_height = doc.createElement ( "height" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_width.appendChild ( doc.createTextNode ( str ( width ) ) )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_height.appendChild ( doc.createTextNode ( str ( height ) ) )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_anamorphic = doc.createElement ( "anamorphic" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_anamorphic.appendChild ( doc.createTextNode ( "FALSE" ) )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_pixelaspectratio = doc.createElement ( "pixelaspectratio" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_pixelaspectratio.appendChild ( doc.createTextNode ( "square" ) )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_fielddominance = doc.createElement ( "fielddominance" )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics_fielddominance.appendChild ( doc.createTextNode ( "none" ) )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_rate )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_width )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_height )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_anamorphic )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_pixelaspectratio )
    sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics_fielddominance )
    sequence_media_video_track_clipitem_media_video.appendChild ( sequence_media_video_track_clipitem_media_video_samplecharacteristics )
    sequence_media_video_track_clipitem_media.appendChild ( sequence_media_video_track_clipitem_media_video )
    if clip.audio is None :
        pass
    else :
        sequence_media_video_track_clipitem_media_audio = doc.createElement ( "audio" )
        sequence_media_video_track_clipitem_media_samplecharacteristics = doc.createElement ( "samplecharacteristics" )
        sequence_media_video_track_clipitem_media_samplecharacteristics_depth = doc.createElement ( "depth" )
        sequence_media_video_track_clipitem_media_samplecharacteristics_depth.appendChild ( doc.createTextNode ( "16" ) )
        sequence_media_video_track_clipitem_media_samplecharacteristics_samplerate = doc.createElement ( "samplerate" )
        sequence_media_video_track_clipitem_media_samplecharacteristics_samplerate.appendChild ( doc.createTextNode ( "48000" ) )
        sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_samplecharacteristics )
        sequence_media_video_track_clipitem_media_video_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_samplecharacteristics_samplerate )
        sequence_media_video_track_clipitem_media_audio_channelcount = doc.createElement ( "channelcount" )
        sequence_media_video_track_clipitem_media_audio_channelcount.appendChild ( doc.createTextNode ( "1" ) )
        sequence_media_video_track_clipitem_media_audio_audiochannel = doc.createElement ( "audiochannel" )
        sequence_media_video_track_clipitem_media_audio_audiochannel_sourcechannel = doc.createElement ( "sourcechannel" )
        sequence_media_video_track_clipitem_media_audio.appendChild ( sequence_media_video_track_clipitem_media_samplecharacteristics )
        sequence_media_video_track_clipitem_media_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_samplecharacteristics_depth )
        sequence_media_video_track_clipitem_media_samplecharacteristics.appendChild ( sequence_media_video_track_clipitem_media_samplecharacteristics_samplerate )
        sequence_media_video_track_clipitem_media_audio.appendChild ( sequence_media_video_track_clipitem_media_audio_channelcount )
        sequence_media_video_track_clipitem_media_audio.appendChild ( sequence_media_video_track_clipitem_media_audio_audiochannel )
        sequence_media_video_track_clipitem_media_audio_audiochannel.appendChild ( sequence_media_video_track_clipitem_media_audio_audiochannel_sourcechannel )
        sequence_media_video_track_clipitem_media.appendChild ( sequence_media_video_track_clipitem_media_audio )

    sequence_media_video_track_clipitem_file.appendChild ( sequence_media_video_track_clipitem_file_name )
    sequence_media_video_track_clipitem_file.appendChild ( sequence_media_video_track_clipitem_file_pathurl )
    sequence_media_video_track_clipitem_file.appendChild ( sequence_media_video_track_clipitem_file_rate )
    sequence_media_video_track_clipitem_file.appendChild ( sequence_media_video_track_clipitem_file_duration )
    sequence_media_video_track_clipitem_file.appendChild ( sequence_media_video_track_clipitem_file_timecode )
    sequence_media_video_track_clipitem_file.appendChild ( sequence_media_video_track_clipitem_media )

    sequence_media_video_track_clipitem_logginginfo = doc.createElement ( "logginginfo" )
    sequence_media_video_track_clipitem_logginginfo_description = doc.createElement ( "description" )
    sequence_media_video_track_clipitem_logginginfo_description.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_logginginfo_scene = doc.createElement ( "scene" )
    sequence_media_video_track_clipitem_logginginfo_scene.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_logginginfo_shottake = doc.createElement ( "shottake" )
    sequence_media_video_track_clipitem_logginginfo_shottake.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_logginginfo_lognote = doc.createElement ( "lognote" )
    sequence_media_video_track_clipitem_logginginfo_lognote.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_logginginfo_good = doc.createElement ( "good" )
    sequence_media_video_track_clipitem_logginginfo_good.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_logginginfo_originalvideofilenamed = doc.createElement ( "originalvideofilename" )
    sequence_media_video_track_clipitem_logginginfo_originalvideofilenamed.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_logginginfo_originalaudiofilename = doc.createElement ( "originalaudiofilename" )
    sequence_media_video_track_clipitem_logginginfo_originalaudiofilename.appendChild ( doc.createTextNode ( "" ) )

    sequence_media_video_track_clipitem_logginginfo.appendChild ( sequence_media_video_track_clipitem_logginginfo_description )
    sequence_media_video_track_clipitem_logginginfo.appendChild ( sequence_media_video_track_clipitem_logginginfo_scene )
    sequence_media_video_track_clipitem_logginginfo.appendChild ( sequence_media_video_track_clipitem_logginginfo_shottake )
    sequence_media_video_track_clipitem_logginginfo.appendChild ( sequence_media_video_track_clipitem_logginginfo_lognote )
    sequence_media_video_track_clipitem_logginginfo.appendChild ( sequence_media_video_track_clipitem_logginginfo_good )
    sequence_media_video_track_clipitem_logginginfo.appendChild ( sequence_media_video_track_clipitem_logginginfo_originalvideofilenamed )
    sequence_media_video_track_clipitem_logginginfo.appendChild ( sequence_media_video_track_clipitem_logginginfo_originalaudiofilename )

    if clip.audio is None :
        pass
    else :

        audio_set.append ( files [ file ] )
        # print (audio_set)
        for i in range ( len ( audio_set ) ) :
            audio_index = 1
            audio_index = audio_index + i
        sequence_media_video_track_clipitem_video_link = doc.createElement ( "link" )
        sequence_media_video_track_clipitem_linkclipref = doc.createElement ( "linkclipref" )
        sequence_media_video_track_clipitem_linkclipref.appendChild ( doc.createTextNode ( linkclipref_video ) )
        sequence_media_video_track_clipitem_mediatype = doc.createElement ( "mediatype" )
        sequence_media_video_track_clipitem_mediatype.appendChild ( doc.createTextNode ( "video" ) )
        sequence_media_video_track_clipitem_trackindex = doc.createElement ( "trackindex" )
        sequence_media_video_track_clipitem_trackindex.appendChild ( doc.createTextNode ( "1" ) )
        sequence_media_video_track_clipitem_clipindex = doc.createElement ( "clipindex" )
        sequence_media_video_track_clipitem_clipindex.appendChild ( doc.createTextNode ( str ( file + 1 ) ) )

        sequence_media_video_track_clipitem_video_link.appendChild ( sequence_media_video_track_clipitem_linkclipref )
        sequence_media_video_track_clipitem_video_link.appendChild ( sequence_media_video_track_clipitem_mediatype )
        sequence_media_video_track_clipitem_video_link.appendChild ( sequence_media_video_track_clipitem_trackindex )
        sequence_media_video_track_clipitem_video_link.appendChild ( sequence_media_video_track_clipitem_clipindex )

        sequence_media_video_track_clipitem_audio_link = doc.createElement ( "link" )
        sequence_media_video_track_clipitem_linkclipref = doc.createElement ( "linkclipref" )
        sequence_media_video_track_clipitem_linkclipref.appendChild ( doc.createTextNode ( linkclipref_audio ) )
        sequence_media_video_track_clipitem_mediatype = doc.createElement ( "mediatype" )
        sequence_media_video_track_clipitem_mediatype.appendChild ( doc.createTextNode ( "audio" ) )
        sequence_media_video_track_clipitem_trackindex = doc.createElement ( "trackindex" )
        sequence_media_video_track_clipitem_trackindex.appendChild ( doc.createTextNode ( "1" ) )
        sequence_media_video_track_clipitem_clipindex = doc.createElement ( "clipindex" )
        sequence_media_video_track_clipitem_clipindex.appendChild ( doc.createTextNode ( str ( audio_index ) ) )
        sequence_media_video_track_clipitem_groupindex = doc.createElement ( "groupindex" )
        sequence_media_video_track_clipitem_groupindex.appendChild ( doc.createTextNode ( "1" ) )

        sequence_media_video_track_clipitem_audio_link.appendChild ( sequence_media_video_track_clipitem_linkclipref )
        sequence_media_video_track_clipitem_audio_link.appendChild ( sequence_media_video_track_clipitem_mediatype )
        sequence_media_video_track_clipitem_audio_link.appendChild ( sequence_media_video_track_clipitem_trackindex )
        sequence_media_video_track_clipitem_audio_link.appendChild ( sequence_media_video_track_clipitem_clipindex )
        sequence_media_video_track_clipitem_audio_link.appendChild ( sequence_media_video_track_clipitem_groupindex )

        sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_video_link )
        sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_audio_link )

    sequence_media_video_track_clipitem_colorinfo = doc.createElement ( "colorinfo" )
    sequence_media_video_track_clipitem_colorinfo_lut = doc.createElement ( "lut" )
    sequence_media_video_track_clipitem_colorinfo_lut.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_colorinfo_lut1 = doc.createElement ( "lut1" )
    sequence_media_video_track_clipitem_colorinfo_lut1.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_colorinfo_asc_sop = doc.createElement ( "asc_sop" )
    sequence_media_video_track_clipitem_colorinfo_asc_sop.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_colorinfo_asc_sat = doc.createElement ( "asc_sat" )
    sequence_media_video_track_clipitem_colorinfo_asc_sat.appendChild ( doc.createTextNode ( "" ) )
    sequence_media_video_track_clipitem_colorinfo_lut2 = doc.createElement ( "lut2" )
    sequence_media_video_track_clipitem_colorinfo_lut2.appendChild ( doc.createTextNode ( "" ) )

    sequence_media_video_track_clipitem_colorinfo.appendChild ( sequence_media_video_track_clipitem_colorinfo_lut )
    sequence_media_video_track_clipitem_colorinfo.appendChild ( sequence_media_video_track_clipitem_colorinfo_lut1 )
    sequence_media_video_track_clipitem_colorinfo.appendChild ( sequence_media_video_track_clipitem_colorinfo_asc_sop )
    sequence_media_video_track_clipitem_colorinfo.appendChild ( sequence_media_video_track_clipitem_colorinfo_asc_sat )
    sequence_media_video_track_clipitem_colorinfo.appendChild ( sequence_media_video_track_clipitem_colorinfo_lut2 )

    sequence_media_video_track_clipitem_labels = doc.createElement ( "labels" )
    sequence_media_video_track_clipitem_labels_label2 = doc.createElement ( "label2" )
    sequence_media_video_track_clipitem_labels_label2.appendChild ( doc.createTextNode ( "Iris" ) )

    sequence_media_video_track_clipitem_labels.appendChild ( sequence_media_video_track_clipitem_labels_label2 )

    sequence_media_video_track_enabled = doc.createElement ( "enabled" )
    sequence_media_video_track_enabled.appendChild ( doc.createTextNode ( "TRUE" ) )
    sequence_media_video_track_locked = doc.createElement ( "locked" )
    sequence_media_video_track_locked.appendChild ( doc.createTextNode ( "FALSE" ) )

    sequence_media_video_track.appendChild ( sequence_media_video_track_clipitem )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_masterclipid )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_name )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_enabled )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_duration )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_rate )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_start )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_end )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_in )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_out )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_pproTicksIn )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_pproTicksOut )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_alphatype )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_pixelaspectratio )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_anamorphic )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_file )

    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_logginginfo )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_colorinfo )
    sequence_media_video_track_clipitem.appendChild ( sequence_media_video_track_clipitem_labels )

    sequence_media_video_track.appendChild ( sequence_media_video_track_enabled )
    sequence_media_video_track.appendChild ( sequence_media_video_track_locked )

    # 从视频文件创建一个VideoFileClip对象

    if clip.audio is None :
        pass
    else :

        # 音频
        sequence_media_audio_track_clipitem = doc.createElement ( 'clipitem' )
        sequence_media_audio_track_clipitem.setAttribute ( 'id', clipitem_audio_Id )
        sequence_media_audio_track_clipitem.setAttribute ( 'premiereChannelType', "mono" )

        sequence_media_audio_track_clipitem_masterclipid = doc.createElement ( 'masterclipid' )
        sequence_media_audio_track_clipitem_masterclipid.appendChild ( doc.createTextNode ( masterclipid ) )

        sequence_media_audio_track_clipitem_name = doc.createElement ( 'name' )
        sequence_media_audio_track_clipitem_name.appendChild ( doc.createTextNode ( fileName ) )

        sequence_media_audio_track_clipitem_enabled = doc.createElement ( 'enabled' )
        sequence_media_audio_track_clipitem_enabled.appendChild ( doc.createTextNode ( "TRUE" ) )

        sequence_media_audio_track_clipitem_duration = doc.createElement ( 'duration' )
        sequence_media_audio_track_clipitem_duration.appendChild ( doc.createTextNode ( str ( n_frames ) ) )

        sequence_media_audio_track_clipitem_rate = doc.createElement ( 'rate' )

        sequence_media_audio_track_clipitem_rate_timebase = doc.createElement ( 'timebase' )
        sequence_media_audio_track_clipitem_rate_timebase.appendChild ( doc.createTextNode ( frame_rate ) )

        sequence_media_audio_track_clipitem_rate_ntsc = doc.createElement ( 'ntsc' )
        sequence_media_audio_track_clipitem_rate_ntsc.appendChild ( doc.createTextNode ( "FALSE" ) )

        sequence_media_audio_track_clipitem_rate.appendChild ( sequence_media_audio_track_clipitem_rate_timebase )
        sequence_media_audio_track_clipitem_rate.appendChild ( sequence_media_audio_track_clipitem_rate_ntsc )

        sequence_media_audio_track_clipitem_start = doc.createElement ( 'start' )
        sequence_media_audio_track_clipitem_start.appendChild ( doc.createTextNode ( str ( end_frames - n_frames ) ) )

        sequence_media_audio_track_clipitem_end = doc.createElement ( 'end' )
        sequence_media_audio_track_clipitem_end.appendChild ( doc.createTextNode ( str ( end_frames ) ) )

        sequence_media_audio_track_clipitem_in = doc.createElement ( 'in' )
        sequence_media_audio_track_clipitem_in.appendChild ( doc.createTextNode ( "0" ) )

        sequence_media_audio_track_clipitem_out = doc.createElement ( 'out' )
        sequence_media_audio_track_clipitem_out.appendChild ( doc.createTextNode ( str ( n_frames ) ) )

        sequence_media_audio_track_clipitem_pproTicksIn = doc.createElement ( 'pproTicksIn' )
        sequence_media_audio_track_clipitem_pproTicksIn.appendChild ( doc.createTextNode ( "0" ) )

        sequence_media_audio_track_clipitem_pproTicksOut = doc.createElement ( 'pproTicksOut' )
        sequence_media_audio_track_clipitem_pproTicksOut.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_file = doc.createElement ( 'file' )
        sequence_media_audio_track_clipitem_file.setAttribute ( 'id', 'file-' + str ( file ) )

        sequence_media_audio_track_clipitem_sourcetrack = doc.createElement ( 'sourcetrack' )
        sequence_media_audio_track_clipitem_sourcetrack_mediatype = doc.createElement ( 'mediatype' )
        sequence_media_audio_track_clipitem_sourcetrack_mediatype.appendChild ( doc.createTextNode ( "audio" ) )

        sequence_media_audio_track_clipitem_sourcetrack_trackindex = doc.createElement ( 'trackindex' )
        sequence_media_audio_track_clipitem_sourcetrack_trackindex.appendChild ( doc.createTextNode ( "1" ) )
        sequence_media_audio_track_clipitem_sourcetrack.appendChild ( sequence_media_audio_track_clipitem_sourcetrack_mediatype )
        sequence_media_audio_track_clipitem_sourcetrack.appendChild ( sequence_media_audio_track_clipitem_sourcetrack_trackindex )

        sequence_media_audio_track_clipitem_video_link = doc.createElement ( 'link' )
        sequence_media_audio_track_clipitem_video_link_linkclipref = doc.createElement ( 'linkclipref' )
        sequence_media_audio_track_clipitem_video_link_linkclipref.appendChild ( doc.createTextNode ( linkclipref_video ) )
        sequence_media_audio_track_clipitem_video_link_mediatype = doc.createElement ( 'mediatype' )
        sequence_media_audio_track_clipitem_video_link_mediatype.appendChild ( doc.createTextNode ( "video" ) )
        sequence_media_audio_track_clipitem_video_link_trackindex = doc.createElement ( 'trackindex' )
        sequence_media_audio_track_clipitem_video_link_trackindex.appendChild ( doc.createTextNode ( "1" ) )
        sequence_media_audio_track_clipitem_video_link_clipindex = doc.createElement ( 'clipindex' )
        sequence_media_audio_track_clipitem_video_link_clipindex.appendChild ( doc.createTextNode ( str ( file + 1 ) ) )
        sequence_media_audio_track_clipitem_video_link.appendChild ( sequence_media_audio_track_clipitem_video_link_linkclipref )
        sequence_media_audio_track_clipitem_video_link.appendChild ( sequence_media_audio_track_clipitem_video_link_mediatype )
        sequence_media_audio_track_clipitem_video_link.appendChild ( sequence_media_audio_track_clipitem_video_link_trackindex )
        sequence_media_audio_track_clipitem_video_link.appendChild ( sequence_media_audio_track_clipitem_video_link_clipindex )

        sequence_media_audio_track_clipitem_audio_link = doc.createElement ( 'link' )
        sequence_media_audio_track_clipitem_audio_link_linkclipref = doc.createElement ( 'linkclipref' )
        sequence_media_audio_track_clipitem_audio_link_linkclipref.appendChild ( doc.createTextNode ( linkclipref_audio ) )
        sequence_media_audio_track_clipitem_audio_link_mediatype = doc.createElement ( 'mediatype' )
        sequence_media_audio_track_clipitem_audio_link_mediatype.appendChild ( doc.createTextNode ( "audio" ) )
        sequence_media_audio_track_clipitem_audio_link_trackindex = doc.createElement ( 'trackindex' )
        sequence_media_audio_track_clipitem_audio_link_trackindex.appendChild ( doc.createTextNode ( "1" ) )
        sequence_media_audio_track_clipitem_audio_link_clipindex = doc.createElement ( 'clipindex' )
        sequence_media_audio_track_clipitem_audio_link_clipindex.appendChild ( doc.createTextNode ( str ( audio_index ) ) )
        sequence_media_audio_track_clipitem_audio_link_groupindex = doc.createElement ( 'groupindex' )
        sequence_media_audio_track_clipitem_audio_link_groupindex.appendChild ( doc.createTextNode ( "1" ) )
        sequence_media_audio_track_clipitem_audio_link.appendChild ( sequence_media_audio_track_clipitem_audio_link_linkclipref )
        sequence_media_audio_track_clipitem_audio_link.appendChild ( sequence_media_audio_track_clipitem_audio_link_mediatype )
        sequence_media_audio_track_clipitem_audio_link.appendChild ( sequence_media_audio_track_clipitem_audio_link_trackindex )
        sequence_media_audio_track_clipitem_audio_link.appendChild ( sequence_media_audio_track_clipitem_audio_link_clipindex )
        sequence_media_audio_track_clipitem_audio_link.appendChild ( sequence_media_audio_track_clipitem_audio_link_groupindex )

        sequence_media_audio_track_clipitem_logginginfo = doc.createElement ( 'logginginfo' )
        sequence_media_audio_track_clipitem_logginginfo_description = doc.createElement ( 'description' )
        sequence_media_audio_track_clipitem_logginginfo_description.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_logginginfo_scene = doc.createElement ( 'scene' )
        sequence_media_audio_track_clipitem_logginginfo_scene.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_logginginfo_shottake = doc.createElement ( 'shottake' )
        sequence_media_audio_track_clipitem_logginginfo_shottake.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_logginginfo_lognote = doc.createElement ( 'lognote' )
        sequence_media_audio_track_clipitem_logginginfo_lognote.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_logginginfo_good = doc.createElement ( 'good' )
        sequence_media_audio_track_clipitem_logginginfo_good.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_logginginfo_originalvideofilename = doc.createElement ( 'originalvideofilename' )
        sequence_media_audio_track_clipitem_logginginfo_originalvideofilename.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_logginginfo_originalaudiofilename = doc.createElement ( 'originalaudiofilename' )
        sequence_media_audio_track_clipitem_logginginfo_originalaudiofilename.appendChild ( doc.createTextNode ( "" ) )

        sequence_media_audio_track_clipitem_logginginfo.appendChild ( sequence_media_audio_track_clipitem_logginginfo_description )
        sequence_media_audio_track_clipitem_logginginfo.appendChild ( sequence_media_audio_track_clipitem_logginginfo_scene )
        sequence_media_audio_track_clipitem_logginginfo.appendChild ( sequence_media_audio_track_clipitem_logginginfo_shottake )
        sequence_media_audio_track_clipitem_logginginfo.appendChild ( sequence_media_audio_track_clipitem_logginginfo_lognote )
        sequence_media_audio_track_clipitem_logginginfo.appendChild ( sequence_media_audio_track_clipitem_logginginfo_good )
        sequence_media_audio_track_clipitem_logginginfo.appendChild ( sequence_media_audio_track_clipitem_logginginfo_originalvideofilename )
        sequence_media_audio_track_clipitem_logginginfo.appendChild ( sequence_media_audio_track_clipitem_logginginfo_originalaudiofilename )

        sequence_media_audio_track_clipitem_colorinfo = doc.createElement ( 'colorinfo' )
        sequence_media_audio_track_clipitem_colorinfo_lut = doc.createElement ( 'lut' )
        sequence_media_audio_track_clipitem_colorinfo_lut.appendChild ( doc.createTextNode ( "" ) )
        sequence_media_audio_track_clipitem_colorinfo_lut1 = doc.createElement ( 'lut1' )
        sequence_media_audio_track_clipitem_colorinfo_lut1.appendChild ( doc.createTextNode ( "" ) )
        sequence_media_audio_track_clipitem_colorinfo_asc_sop = doc.createElement ( 'asc_sop' )
        sequence_media_audio_track_clipitem_colorinfo_asc_sop.appendChild ( doc.createTextNode ( "" ) )
        sequence_media_audio_track_clipitem_colorinfo_asc_sat = doc.createElement ( 'asc_sat' )
        sequence_media_audio_track_clipitem_colorinfo_asc_sat.appendChild ( doc.createTextNode ( "" ) )
        sequence_media_audio_track_clipitem_colorinfo_lut2 = doc.createElement ( 'lut2' )
        sequence_media_audio_track_clipitem_colorinfo_lut2.appendChild ( doc.createTextNode ( "" ) )
        sequence_media_audio_track_clipitem_colorinfo.appendChild ( sequence_media_audio_track_clipitem_colorinfo_lut )
        sequence_media_audio_track_clipitem_colorinfo.appendChild ( sequence_media_audio_track_clipitem_colorinfo_lut1 )
        sequence_media_audio_track_clipitem_colorinfo.appendChild ( sequence_media_audio_track_clipitem_colorinfo_asc_sop )
        sequence_media_audio_track_clipitem_colorinfo.appendChild ( sequence_media_audio_track_clipitem_colorinfo_asc_sat )
        sequence_media_audio_track_clipitem_colorinfo.appendChild ( sequence_media_audio_track_clipitem_colorinfo_lut2 )

        sequence_media_audio_track_clipitem_labels = doc.createElement ( 'labels' )
        sequence_media_audio_track_clipitem_labels_label2 = doc.createElement ( 'label2' )
        sequence_media_audio_track_clipitem_labels_label2.appendChild ( doc.createTextNode ( "Iris" ) )
        sequence_media_audio_track_clipitem_labels.appendChild ( sequence_media_audio_track_clipitem_labels_label2 )

        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_masterclipid )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_name )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_enabled )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_duration )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_rate )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_start )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_end )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_in )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_out )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_pproTicksIn )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_pproTicksOut )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_file )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_sourcetrack )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_video_link )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_audio_link )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_logginginfo )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_colorinfo )
        sequence_media_audio_track_clipitem.appendChild ( sequence_media_audio_track_clipitem_labels )

        sequence_media_audio_track.appendChild ( sequence_media_audio_track_clipitem )
    start_frames = int ( start_frames ) + int ( n_frames )
# 剪辑总帧数
sequence_duration.appendChild ( doc.createTextNode ( str ( sequence_duration_str ) ) )

# 剪辑尺寸
sequence_media_video_format_samplecharacteristics_width.appendChild ( doc.createTextNode ( str ( width ) ) )
sequence_media_video_format_samplecharacteristics_height.appendChild ( doc.createTextNode ( str ( height ) ) )

sequence_media_video.appendChild ( sequence_media_video_track )

sequence_media.appendChild ( sequence_media_video )
sequence_media.appendChild ( sequence_media_audio )
Sequence.appendChild ( sequence_media )
root.appendChild ( Sequence )

with open ( 'H:/QL_tool_file/Window_Tool/Logical File/PR_CreateClips/home.xml', 'w', encoding='utf-8' ) as f :
    doc.writexml ( f, addindent='\t', indent='\t', newl='\n' )
